//
//  HomeViewController.m
//  dyseller
//
//  Created by 红喇叭 on 2017/8/14.
//  Copyright © 2017年 红喇叭. All rights reserved.
//

#import "HomeViewController.h"
#import "FinancialViewController.h"
#import "OrderManageControl.h"
#import "NoctionTableView.h"
#import "NoctionTableView.h"
#import "HLBTabBarVC.h"

@interface HomeViewController (){
    NSDictionary *agentInfo;
    NSDictionary *data;
    NoctionTableView *_tablew;
}
@property (strong, nonatomic) UIImageView *storeIMG;//店铺头像
@property (strong, nonatomic)UILabel *storeLab;//店铺头像下的 店铺名字
@property (strong, nonatomic)UIButton *scanBtn;//扫码
@property(strong,nonatomic)UIButton *orderBtn;//订单管理
@property (strong, nonatomic) UIButton *cwBtn;//财务管理
@property (strong, nonatomic) UIButton *xiaoxBtn;
@property (strong, nonatomic)  UILabel *shopname;//门店名称
@property (strong, nonatomic)  UILabel *xiaofMoney;//消费的money
@property (strong, nonatomic)  UILabel *xiaofBJ;//消费比较
@property (strong, nonatomic) UILabel *ddNumber;//订单数量
@property (strong, nonatomic) UILabel *ddBJ;//订单比较
@property (strong, nonatomic)  UILabel *NewsBJ;//新客数的比较
@property (strong, nonatomic)  UILabel *kehBJ;//前天的客数比较
@property (strong, nonatomic) UILabel *PJNumber;//评价数

@property (strong, nonatomic) UILabel *pjBJ;//好评数
@property(strong,nonatomic)UILabel *cpNumber;//差评数

@property (strong, nonatomic) UIView *noctionView;//滚动视图的载体

@end

@implementation HomeViewController
- (void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (instancetype)init{
    self = [super init];
    if(self){
        [self layoutView];
    }
    return  self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self loadNoticList];
    
    [self loadingData];
    
    //接收收到新订单的推送，此时重新加载滚动数据
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loadNoticList) name:@"news_order" object:nil];

   
}
- (void)viewDidLayoutSubviews{
    [self detectionInformation];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
     [self.navigationController setNavigationBarHidden:YES animated:animated];
    
    
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
    
}

//检测推送权限是否开启
- (void)detectionInformation{
    if ([[UIApplication sharedApplication] currentUserNotificationSettings].types  == UIRemoteNotificationTypeNone) {
        
        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"请开启推送权限！！" preferredStyle:UIAlertControllerStyleAlert];
        //添加取消到UIAlertController中
        [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
            
        }]];
        
        [alertController addAction:[UIAlertAction actionWithTitle:@"去设置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
            NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
            
            if([[UIApplication sharedApplication] canOpenURL:url]) {
                
                NSURL*url =[NSURL URLWithString:UIApplicationOpenSettingsURLString];
                [[UIApplication sharedApplication] openURL:url];
            }
            
        }]];
        
        [self presentViewController:alertController animated:YES completion:nil];
        
    }

}

- (void)layoutView{
    UIView *topView = [[UIView alloc] init];
    topView.backgroundColor = UIColorFromRGB(0xe71a41);
    [self.view addSubview:topView];
    topView.sd_layout.topSpaceToView(self.view, 0).leftSpaceToView(self.view, 0).rightSpaceToView(self.view, 0).heightIs(GETHEIGHT(430));
    
    _storeIMG = [[UIImageView alloc] init];
    _storeIMG.image = [UIImage imageNamed:@"home_head_icon_default.png"];
    _storeIMG.layer.cornerRadius = GETWITH(66);
    _storeIMG.layer.masksToBounds = YES;

    [topView addSubview:_storeIMG];
    if(SCREEN_H == 812){
       _storeIMG.sd_layout.topSpaceToView(topView,70).centerXEqualToView(topView).widthIs(GETWITH(132)).heightEqualToWidth();
    }else{
        _storeIMG.sd_layout.topSpaceToView(topView, GETHEIGHT(68)).centerXEqualToView(topView).widthIs(GETWITH(132)).heightEqualToWidth();
    }
    
    
    _storeLab = [[UILabel alloc] init];
    _storeLab.textAlignment = NSTextAlignmentCenter;
    _storeLab.font = font14;
    _storeLab.textColor = UIColorFromRGB(0xffffff);
    [topView addSubview:_storeLab];
    _storeLab.sd_layout.topSpaceToView(_storeIMG, GETHEIGHT(22)).leftSpaceToView(topView, 0).rightSpaceToView(topView, 0).autoHeightRatio(0);
    
    _scanBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_scanBtn setImage:[UIImage imageNamed:@"home_icon1_default.png"] forState:UIControlStateNormal];
    [topView addSubview:_scanBtn];
    _scanBtn.sd_layout.leftSpaceToView(topView, GETHEIGHT(90)).topSpaceToView(_storeIMG, GETHEIGHT(100)).widthIs(GETWITH(54)).heightEqualToWidth();
    
    UIButton *scanLab = [[UIButton alloc] init];
    scanLab.titleLabel.font = font14;
    scanLab.titleLabel.textColor = [UIColor whiteColor];
    [scanLab setTitle:@"扫码验证" forState:UIControlStateNormal];
    [topView addSubview:scanLab];
    scanLab.sd_layout.widthIs(GETWITH(140)).heightIs(GETHEIGHT(28)).centerXEqualToView(_scanBtn).topSpaceToView(_scanBtn, GETHEIGHT(16));
    
    UIButton *btn1 = [[UIButton alloc] init];
    [topView addSubview:btn1];
    btn1.sd_layout.heightIs(GETHEIGHT(88)).widthIs(GETWITH(140)).centerXEqualToView(_scanBtn).topEqualToView(_scanBtn);
    [btn1 addTarget:self action:@selector(scanAction:) forControlEvents:UIControlEventTouchUpInside];
    
    _orderBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_orderBtn setBackgroundImage:[UIImage imageNamed:@"home_icon2_default_nor.png"] forState:UIControlStateNormal];
    [topView addSubview:_orderBtn];
    _orderBtn.sd_layout.widthIs(GETWITH(54)).heightEqualToWidth().topEqualToView(_scanBtn).centerXEqualToView(topView);
    
    UIButton *scanLab1 = [[UIButton alloc] init];
    scanLab1.titleLabel.font = font14;
    scanLab1.titleLabel.textColor = [UIColor whiteColor];
    [scanLab1 setTitle:@"订单管理" forState:UIControlStateNormal];
    [topView addSubview:scanLab1];
    scanLab1.sd_layout.widthIs(GETWITH(140)).heightIs(GETHEIGHT(28)).centerXEqualToView(_orderBtn).topSpaceToView(_orderBtn, GETHEIGHT(16));
    
    UIButton *btn2 = [[UIButton alloc] init];
    [topView addSubview:btn2];
    btn2.sd_layout.heightIs(GETHEIGHT(88)).widthIs(GETWITH(140)).centerXEqualToView(_orderBtn).topEqualToView(_scanBtn);
    [btn2 addTarget:self action:@selector(OrderMangen:) forControlEvents:UIControlEventTouchUpInside];
    
    _cwBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_cwBtn setBackgroundImage:[UIImage imageNamed:@"home_icon3_default_nor.png"] forState:UIControlStateNormal];
    [topView addSubview:_cwBtn];
    _cwBtn.sd_layout.widthIs(GETWITH(54)).heightEqualToWidth().topEqualToView(_scanBtn).rightSpaceToView(topView, GETWITH(90));
    
    UIButton *scanLab2 = [[UIButton alloc] init];
    scanLab2.titleLabel.font = font14;
    scanLab2.titleLabel.textColor = [UIColor whiteColor];
    [scanLab2 setTitle:@"财务管理" forState:UIControlStateNormal];
    [topView addSubview:scanLab2];
    scanLab2.sd_layout.widthIs(GETWITH(140)).heightIs(GETHEIGHT(28)).centerXEqualToView(_cwBtn).topSpaceToView(_cwBtn, GETHEIGHT(16));
    
    UIButton *btn3 = [[UIButton alloc] init];
    [topView addSubview:btn3];
    btn3.sd_layout.heightIs(GETHEIGHT(88)).widthIs(GETWITH(140)).centerXEqualToView(_cwBtn).topEqualToView(_scanBtn);
    [btn3 addTarget:self action:@selector(FinanCiaAction:) forControlEvents:UIControlEventTouchUpInside];
    
    _xiaoxBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_xiaoxBtn setBackgroundImage:[UIImage imageNamed:@"home_T_icon2_default_nor.png"] forState:UIControlStateNormal];
    [self.view addSubview:_xiaoxBtn];
    _xiaoxBtn.sd_layout.topSpaceToView(topView, GETHEIGHT(40)).leftSpaceToView(self.view, GETWITH(30)).widthIs(GETWITH(64)).heightIs(GETHEIGHT(58));
    
    _noctionView = [[UIView alloc] init];
    [self.view addSubview:_noctionView];
    _noctionView.sd_layout.leftSpaceToView(_xiaoxBtn, GETWITH(28)).topSpaceToView(topView, 0).rightSpaceToView(self.view, GETWITH(40)).heightIs(GETHEIGHT(140));
    
    UIView *fgView = [[UIView alloc] init];
    fgView.backgroundColor = UIColorFromRGB(0xEBEBEB);
    [self.view addSubview:fgView];
    fgView.sd_layout.leftEqualToView(topView).topSpaceToView(_noctionView, 0).rightEqualToView(topView).heightIs(GETHEIGHT(20));
    
    UIImageView *leftImg = [[UIImageView alloc] init];
    leftImg.image  = [UIImage imageNamed:@"home_T_icon_default_nor.png"];
    [self.view addSubview:leftImg];
    leftImg.sd_layout.leftEqualToView(_xiaoxBtn).topSpaceToView(fgView, GETHEIGHT(40)).widthIs(GETWITH(64)).heightIs(GETHEIGHT(58));
    
    UILabel *lab1 = [[UILabel alloc] init];
    lab1.text = @"门店经营数据";
    lab1.textColor = UIColorFromRGB(0x333333);
    lab1.font = [UIFont fontWithName:@"Helvetica-Bold" size:14*H];
    [self.view addSubview:lab1];
    lab1.sd_layout.leftEqualToView(_noctionView).topEqualToView(leftImg).widthIs(0).autoHeightRatio(0);
    [lab1 setSingleLineAutoResizeWithMaxWidth:120];
    
    UIImageView *rightTime = [[UIImageView alloc] init];
    rightTime.image = [UIImage imageNamed:@"home_btn_default_nor.png"];
    [self.view addSubview:rightTime];
    rightTime.sd_layout.rightEqualToView(_noctionView).topEqualToView(lab1).widthIs(GETWITH(180)).heightIs(GETHEIGHT(66));
    
    _shopname = [[UILabel alloc] init];
    _shopname.textColor = UIColorFromRGB(0x666666);
    _shopname.font = font12;
    [self.view addSubview:_shopname];
    _shopname.sd_layout.leftEqualToView(lab1).topSpaceToView(lab1, GETHEIGHT(20)).rightSpaceToView(rightTime, GETWITH(30)).heightIs(GETHEIGHT(24));
    
    UIView *lineV = [[UIView alloc] init];
    lineV.backgroundColor = UIColorFromRGB(0x999999);
    [self.view addSubview:lineV];
    lineV.sd_layout.leftEqualToView(lab1).topSpaceToView(_shopname, GETHEIGHT(30)).rightEqualToView(rightTime).heightIs(GETHEIGHT(1));
    
    UILabel *lab2 = [[UILabel alloc] init];
    lab2.textColor = UIColorFromRGB(0x333333);
    lab2.text = @"消费金额（元）";
    lab2.font = font12;
    [self.view addSubview:lab2];
    lab2.sd_layout.leftEqualToView(lab1).topSpaceToView(_shopname, GETHEIGHT(68)).widthIs(0).heightIs(GETHEIGHT(24));
    [lab2 setSingleLineAutoResizeWithMaxWidth:120];

    _xiaofMoney = [[UILabel alloc] init];
    _xiaofMoney.textColor = UIColorFromRGB(0x333333);
    _xiaofMoney.font = [UIFont fontWithName:@"ArialMT" size:GETHEIGHT(49)];
    [self.view addSubview:_xiaofMoney];
    _xiaofMoney.sd_layout.leftEqualToView(lab2).topSpaceToView(lab2, GETHEIGHT(36)).widthIs(0).heightIs(GETHEIGHT(50));
    [_xiaofMoney setSingleLineAutoResizeWithMaxWidth:200];
    UILabel *lab21 = [[UILabel alloc] init];
    lab21.text = @"较前天";
    lab21.textColor = UIColorFromRGB(0x333333);
    lab21.font = font12;
    [self.view addSubview:lab21];
    lab21.sd_layout.leftEqualToView(lab2).topSpaceToView(_xiaofMoney, GETHEIGHT(36)).widthIs(0).heightIs(GETHEIGHT(24));
    [lab21 setSingleLineAutoResizeWithMaxWidth:100];
    
    _xiaofBJ = [[UILabel alloc] init];
    _xiaofBJ.font = font14;
    _xiaofBJ.textColor = UIColorFromRGB(0x01a879);
    [self.view addSubview:_xiaofBJ];
    _xiaofBJ.sd_layout.leftSpaceToView(lab21, GETWITH(4)).widthIs(0).autoHeightRatio(0).centerYEqualToView(lab21);
    [_xiaofBJ setSingleLineAutoResizeWithMaxWidth:100];
    
    UILabel *lab3 = [[UILabel alloc] init];
    lab3.textColor = UIColorFromRGB(0x333333);
    lab3.textAlignment = NSTextAlignmentLeft;
    lab3.text = @"订单量";
    lab3.font = font12;
    [self.view addSubview:lab3];
    lab3.sd_layout.widthIs(GETWITH(100)).heightIs(GETHEIGHT(24)).leftSpaceToView(lab2, GETWITH(150)).topEqualToView(lab2);
    

    _ddNumber = [[UILabel alloc] init];
    _ddNumber.textAlignment = NSTextAlignmentLeft;
    _ddNumber.textColor = UIColorFromRGB(0x333333);
    _ddNumber.font = [UIFont fontWithName:@"ArialMT" size:GETHEIGHT(49)];
    [self.view addSubview:_ddNumber];
    _ddNumber.sd_layout.leftEqualToView(lab3).topSpaceToView(lab3, GETHEIGHT(36)).widthIs(GETWITH(200)).heightIs(GETHEIGHT(50));
    
    UILabel *lab31 = [[UILabel alloc] init];
    lab31.text = @"较前天";
    lab31.textColor = UIColorFromRGB(0x333333);
    lab31.font = font12;
    lab31.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:lab31];
 lab31.sd_layout.widthIs(GETWITH(100)).heightIs(GETHEIGHT(24)).leftEqualToView(lab3).topSpaceToView(_xiaofMoney, GETHEIGHT(36));
    
    _ddBJ = [[UILabel alloc] init];
    _ddBJ.font = font14;
    _ddBJ.textColor = UIColorFromRGB(0x01a879);
    [self.view addSubview:_ddBJ];
    _ddBJ.sd_layout.widthIs(0).autoHeightRatio(0).centerYEqualToView(lab21).leftSpaceToView(lab31, GETWITH(4));
    [_ddBJ setSingleLineAutoResizeWithMaxWidth:100];
    

    UILabel *lab4 = [[UILabel alloc] init];
    lab4.textColor = UIColorFromRGB(0x333333);
    lab4.text = @"新客数/老客数";
    lab4.font = font12;
    [self.view addSubview:lab4];
    lab4.sd_layout.leftEqualToView(lab21).topSpaceToView(lab21, GETHEIGHT(60)).widthIs(0).heightIs(GETHEIGHT(24));
    [lab4 setSingleLineAutoResizeWithMaxWidth:100];
    
    _NewsBJ = [[UILabel alloc] init];
    _NewsBJ.textColor = UIColorFromRGB(0x333333);
    _NewsBJ.font = [UIFont fontWithName:@"ArialMT" size:GETHEIGHT(49)];
    [self.view addSubview:_NewsBJ];
    _NewsBJ.sd_layout.leftEqualToView(lab4).topSpaceToView(lab4, GETHEIGHT(36)).widthIs(GETWITH(200)).heightIs(GETHEIGHT(50));
    
    UILabel *lab41 = [[UILabel alloc] init];
    lab41.text = @"前天";
    lab41.textColor = UIColorFromRGB(0x333333);
    lab41.font = font12;
    [self.view addSubview:lab41];
    lab41.sd_layout.leftEqualToView(lab4).topSpaceToView(_NewsBJ, GETHEIGHT(36)).widthIs(0).autoHeightRatio(0);
    [lab41 setSingleLineAutoResizeWithMaxWidth:100];
    
    _kehBJ = [[UILabel alloc] init];
    _kehBJ.font = font14;
    _kehBJ.textColor = UIColorFromRGB(0x333333);
    [self.view addSubview:_kehBJ];
    _kehBJ.sd_layout.leftSpaceToView(lab41, GETWITH(4)).widthIs(0).autoHeightRatio(0).centerYEqualToView(lab41);
    [_kehBJ setSingleLineAutoResizeWithMaxWidth:100];
    
    UILabel *lab5 = [[UILabel alloc] init];
    lab5.textColor = UIColorFromRGB(0x333333);
    lab5.text = @"新增评价";
    lab5.font = font12;
    [self.view addSubview:lab5];
 lab5.sd_layout.widthIs(GETWITH(150)).heightIs(GETHEIGHT(24)).leftEqualToView(lab3).topSpaceToView(lab31, GETHEIGHT(60));
    
    
    _PJNumber = [[UILabel alloc] init];
    _PJNumber.textColor = UIColorFromRGB(0x333333);
    _PJNumber.font = [UIFont fontWithName:@"ArialMT" size:GETHEIGHT(49)];
    [self.view addSubview:_PJNumber];
    _PJNumber.sd_layout.leftEqualToView(lab5).topSpaceToView(lab5, GETHEIGHT(36)).widthIs(GETWITH(200)).heightIs(GETHEIGHT(50));
    
    
    _pjBJ = [[UILabel alloc] init];
    _pjBJ.font = font12;
    [self.view addSubview:_pjBJ];
    _pjBJ.sd_layout.widthIs(0).autoHeightRatio(0).leftEqualToView(lab5).topSpaceToView(_PJNumber, GETHEIGHT(36));
    [_pjBJ setSingleLineAutoResizeWithMaxWidth:150];

    _cpNumber = [[UILabel alloc] init];
    _cpNumber.font = font12;
    [self.view addSubview:_cpNumber];
    _cpNumber.sd_layout.leftSpaceToView(_pjBJ, GETWITH(4)).widthIs(0).autoHeightRatio(0).topSpaceToView(_PJNumber, GETHEIGHT(36));
    [_cpNumber setSingleLineAutoResizeWithMaxWidth:100];

    
    
}

#pragma mark 加载数据
//加载门店信息 跟 门店昨天的相关信息
- (void)loadingData{
    
    __weak typeof(self)weakself = self;
    
    [[PPHttpRequsetData shareInstance] requestStyle:Request_POST URL:@"/ShopApi/Index/commonData"  parameter:@{} successBlock:^(PPHttpRequest *request, id responseObj) {
       
        data = responseObj;
        agentInfo = data[@"agentInfo"];
        [userDefaults setObject:agentInfo forKey:@"agentInfo"];
        [weakself setData];
        [weakself removeExceptionView];
    } failBlock:^(PPHttpRequest *request, NSString *errMsg) {
        [weakself addExceptionAlView];
        [AlertUtils showToastWithMessage:errMsg inView:self.view hideAfterDelay:2.0 beIndeter:NO];
    }];

}

//请求轮播的订单数据
- (void)loadNoticList{
    __weak typeof (self)weakself = self;
    [[PPHttpRequsetData shareInstance] requestStyle:Request_POST URL:@"/ShopApi/Index/noticeList" isactive:YES parameter:@{} successBlock:^(PPHttpRequest *request, id responseObj) {
        NSArray *platNotice = responseObj[@"platNotice"];
        NSArray *orderNotice = responseObj[@"orderNotice"];
        NSArray *tabledata ;
        int style = 0;
        if(orderNotice.count>0){
            style = 1;
            tabledata = orderNotice;
        }else{
            style = 0;
            tabledata = platNotice;
        }
        
        //style : 0: 代表今天没有订单，显示系统公告 1：订单数据
        if(_tablew==nil){
            _tablew = [[NoctionTableView alloc] initWithFrame:CGRectMake(0, 0, _noctionView.width, _noctionView.height) tableData:tabledata stlye:style];
            
            [_noctionView addSubview:_tablew];
        }else{
            [_tablew  rloadView:tabledata style:style];
        }
       
        
        [weakself removeExceptionView];
    } failBlock:^(PPHttpRequest *request, NSString *errMsg) {
        [weakself addExceptionAlView];
        [AlertUtils showToastWithMessage:errMsg inView:self.view hideAfterDelay:2.0 beIndeter:NO];
    } ];
}

- (void)buttonAction{
    __weak typeof(self)weakself = self;
    [weakself loadingData];
    [weakself loadNoticList];
}

- (void)setData{

    [_storeIMG sd_setImageWithURL:[NSURL URLWithString:agentInfo[@"headimgurl"]] placeholderImage:[UIImage imageNamed:@"home_head_icon_default.png"]];
  //  [_storeIMG sd_setImageWithURL:[NSURL URLWithString:agentInfo[@"headimgurl"]]];
    _storeLab.text = data[@"agentInfo"][@"agent_name"];
    
    _shopname.text = data[@"agentInfo"][@"agent_name"];
    
    _xiaofMoney.text = [NSString stringWithFormat:@"%@",data[@"payInfo"][@"price"]];
    NSString *str = [NSString stringWithFormat:@"%@",data[@"payInfo"][@"per"]];
    if([data[@"payInfo"][@"per"] intValue] > 0){
        _xiaofBJ.textColor = [UIColor redColor];
    }else{
        _xiaofBJ.textColor = UIColorFromRGB(0x01a879);
    }
    _xiaofBJ.text = [str stringByAppendingString:@"%"];
    
    int ordernum = [data[@"order"][@"num"] intValue];
    _ddNumber.text = [NSString stringWithFormat:@"%d",ordernum];
    NSString *str2 = [NSString stringWithFormat:@"%@",data[@"order"][@"per"]];
    if([data[@"order"][@"per"] intValue]>0){
        _ddBJ.textColor = [UIColor redColor];
    }else{
        _ddBJ.textColor = UIColorFromRGB(0x01a879);
    }
    
    _ddBJ.text = [str2 stringByAppendingString:@"%"];
    
    _NewsBJ.text = [NSString stringWithFormat:@"%d/%d",[data[@"customer"][@"y_new_customer"] intValue],[data[@"oldCustomer"][@"y_old_customer"] intValue]];
    _kehBJ.text = [NSString stringWithFormat:@"%d/%d",[data[@"customer"][@"by_new_customer"] intValue],[data[@"oldCustomer"][@"by_old_customer"] intValue]];
    
    int badComment = [data[@"comment"][@"bad_comment"] intValue];
    int goodComment = [data[@"comment"][@"goods_comment"] intValue];
    int number = badComment + goodComment;
    _PJNumber.text = [NSString stringWithFormat:@"%d",number];
    
    NSString *goodbj = [NSString stringWithFormat:@"%d条好评/",goodComment];
    _pjBJ.attributedText =  [ToolClass AttributedString:goodbj range:NSMakeRange(0,goodbj.length-3) color:[UIColor redColor]];
    
    NSString *badpj = [NSString stringWithFormat:@"%d条中差评",badComment];
    _cpNumber.attributedText =  [ToolClass AttributedString:badpj range:NSMakeRange(0,badpj.length-3) color:[UIColor redColor]];

   
    
    
}


- (void)OrderMangen:(id)sender {
    OrderManageControl *vc = [[OrderManageControl alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
    
}
- (void)FinanCiaAction:(id)sender {
    FinancialViewController *vc = [[FinancialViewController alloc] init];
    vc.title = @"财务管理";
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)scanAction:(id)sender {
    [self scan];
    
}

@end
